<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Sage 2016/4/19  14:05
// +----------------------------------------------------------------------
namespace Wechat\Controller;
use Think\Controller;

//购物车
Class CartController extends BaseController {
    function index() {
        $Cart = M("View_cart_book");
        $map['cart_type'] = 0;
        $map['user_id'] = session("user_id");
        $d = $Cart->where($map)->field("book_id,sm,quantity,b_logo,dj")->select();
        $this->assign("d", $d);
        $this->display();
    }

    //删除背包或购物车内的书
    function deletebook() {
        $book_id = I("post.id");
        $type = I("post.type");
        $user_id = session("user_id");
        $Cart = M("Cart");
        $Cart->where("book_id=$book_id AND type=$type AND user_id=$user_id")->delete();
        echo 1;
    }
}